package com.bw.journal.list


import com.bawei.module_journal.R
import com.bw.journal.list.entity.JournalListEntity
import com.bw.quickadapter.BaseQuickAdapter
import com.bw.quickadapter.BaseViewHolder
import com.bw.widget.design.MonthView
import java.util.*

class JournalAdapter : BaseQuickAdapter<JournalListEntity>(R.layout.item_journal_list) {
    override fun convert(holder: BaseViewHolder?, item: JournalListEntity?) {
        holder!!.let {
            val calendar = Calendar.getInstance()
            calendar.time = Date(item!!.reportTime*1000)
            val monthStr = ""+(calendar.get(Calendar.MONTH) + 1)
            val monthView : MonthView = it.getView(R.id.journal_list_time_month)
            monthView.setTime(monthStr)
            var titleStr = ""
            if (item.reportType == 1)titleStr=""+calendar.get(Calendar.YEAR)+"年"+monthStr+"月"+calendar.get(Calendar.DAY_OF_MONTH)+"日，日报"
            else if (item.reportType == 2)titleStr=""+calendar.get(Calendar.YEAR)+"年"+monthStr+"月"+calendar.get(Calendar.WEEK_OF_MONTH)+"周，周报"
            else titleStr=""+calendar.get(Calendar.YEAR)+"年"+monthStr+"月，月报"
            var nowValue = item.reportNowValue
            if (item.reportRemind!="")nowValue.apply { "$nowValue@$item.reportRemind" }
            it.setText(R.id.journal_list_time_title,titleStr)
            it.setText(R.id.journal_list_now_title,item.reportNowTitle)
            it.setText(R.id.journal_list_now_value,nowValue)
            it.setText(R.id.journal_list_next_title,item.reportNextTitle)
            it.setText(R.id.journal_list_next_value,item.reportNextValue)
            it.setText(R.id.journal_list_time_tv,""+calendar.get(Calendar.YEAR)+
                    "年"+monthStr+"月"+calendar.get(Calendar.DAY_OF_MONTH)+"日发布")

        }
    }
}